{% extends "base.html" %}

{% block title %}Reps{% endblock %}
{% block head %}
<script type="text/javascript">
  $(function() {
    repsTrLink();
    modalOverlay();
  });
</script>
{% endblock %}

{% block header %}{% endblock %}

{% block primary-content %}
<span class="breadcrumbs"><a href="{% url index %}" title="Home">Home</a> &raquo; Reps</span>
<h2>{{ location.site.name }} Representatives</h2>
  <div id="page-controls">
    {% if address %}
    <h3>Displaying reps for:</h3>
    <address>{{ address }}<br />
      {{ city_and_state }}</address>
    {% endif %}
    {% comment %}
    <!-- need to rethink this
    {% if address %}
    <h2>No representatives were found for</h2>
    <address> {{ address }}{% if city_and_state %}, {% endif %}{{ city_and_state }}.</address>
    <p class="error">Please try another.{% ifnotequal city_and_state "Philadelphia, PA" %}  OurPhiladelphia currently provides representative information for Philadelphia addresses only.{% endifnotequal %}</p>
    {% else %}
    <p>Enter your address to look up your representatives.</p>
    {% endif %}
    -->
    {% endcomment %}
    <form id="address-search" class="clearfix">
      <label>Enter an address to find reps</label>
      <input type="text" class="search-input" name="address"/>
      <input type="submit" class="button" value="Search"/>
    </form>
    {% if address %}
    <p><a title="View all reps" href="{% url reps %}?a=1">Or view all Philadelphia reps &raquo;</a></p>
    {% else %}
    {% if user.is_authenticated %}
    <p><a title="View your reps" href="{% url reps %}">Or view your reps &raquo;</a></p>
    {% endif %}
    {% endif %}
  </div>
  {% comment %}
  Do we need this? I think no. 
  <ul id="reps-controls">
    {% if get_address and user.get_profile.reps.all %}
    <li><a href="{% url reps %}">See reps for my address</a></li>
    {% endif %}
    {% if user.is_authenticated %}
    {% if get_address %}
    <form name="save_address" action="{% url reps %}" method="post">
      {% csrf_token %}
      <input type="hidden" name="address" value="{{ address }}" />
    </form>
    <li class="save"><a href="{% url reps %}" onclick="document.forms['save_address'].submit(); return false">Save as my address</a></li>
    {% endif %}
    {% else %}
    <li class="login"><a href="{% url auth_login %}">Log in</a></li>          
    {% endif %}
  </ul>
  {% endcomment %}
  {% if is_reps %}
  <ul id="rep-table-sorter">
    <li{% ifequal current "by_level" %} class="current"{% endifequal %}><a href="{% url reps %}">Sort Reps by Level</a></li>
    <li{% ifequal current "by_name" %} class="current"{% endifequal %}><a href="{% url reps %}?n=1">Sort Reps by Name</a></li>
  </ul>
  {% endif %}
  {% if reps_by_name %}
    <h3 class="float-left">&nbsp;</h3>
    {% with reps_by_name as reps %}
      {% include "reps/snippets/rep_table.html" %}
    {% endwith %}
  {% else %}
    <h3 class="float-left">Local</h3>
    <a class="whats-this" name="modal" href="#local">What's this?</a>
    <div class="modal" id="local">
			<a href="#" class="modal-close">Close it</a>
      <p><strong>Local Reps</strong><br />
				17 City Councilmembers serve four year terms to form the legislative arm of Philadelphia municipal government.  10 of these Councilmembers represent a physical city district while 7 are elected from the "City-at-large."  For this reason, your local representatives include 1 Councilmember by district, the 7 At-Large Councilmembers, and the Mayor of Philadelphia (executive branch).  For more information, see the <a href="http://www.phila.gov/citycouncil/About.html">Philadelphia City Council's website</a>.</p>
    </div>
    {% with local_reps as reps %}
      {% include "reps/snippets/rep_table.html" %}
    {% endwith %}
    <h3 class="float-left">State</h3>
    <a class="whats-this" name="modal" href="#state">What's this?</a>
    <div class="modal" id="state">
			<a href="#" class="modal-close">Close it</a>
      <p><strong>State Reps</strong><br />
				The <a href="http://www.pasen.gov/">State Senate</a> (upper house) and <a href="http://www.house.state.pa.us/">House of Representatives</a> (lower house) form the legislative arm of Pennsylvania state government.  28 State Representative districts and 6 State Senatorial districts overlap the city limits of Philadelphia.  For this reason, your representatives at the state level include 1 Senator, 1 Representative, and the Governor of Pennsylvania (executive branch).</p>
    </div>
    {% with state_reps as reps %}
      {% include "reps/snippets/rep_table.html" %}
    {% endwith %}
    <h3 class="float-left">National</h3>
    <a class="whats-this" name="modal" href="#national">What's this?</a>
    <div class="modal" id="national">
			<a href="#" class="modal-close">Close it</a>
      <p><strong>National Reps</strong><br />
				The <a href="http://www.senate.gov/">United States Senate</a> (upper house) and <a href="http://www.house.gov/">House of Representative</a> (lower house) form the legislative arm of the national government.  4 U.S. Representative districts overlap the city limits of Philadelphia.  Each state in the country has 2 U.S. Senators, who represent the people of the state equally.  For this reason, your national representatives include 1 U.S. Representative, 2 U.S. Senators, and the President of the United States (executive branch).</p>
    </div>
    {% with national_reps as reps %}
      {% include "reps/snippets/rep_table.html" %}
    {% endwith %}
  {% endif %}
	<div id="mask"></div>
{% endblock %}

